package com.smart.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.smart.system.mapper.AlarmMapper;
import com.smart.system.domain.Alarm;
import com.smart.system.service.IAlarmService;

/**
 * 告警Service业务层处理
 *
 * @author smart
 * @date 2024-12-16
 */
@Service
public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements IAlarmService {

    /**
     * 查询告警
     *
     * @param id 告警主键
     * @return 告警
     */
    @Override
    public Alarm selectAlarmById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询告警列表
     *
     * @param alarm 告警
     * @return 告警
     */
    @Override
    public List<Alarm> selectAlarmList(Alarm alarm) {
        return this.list();
    }

    /**
     * 新增告警
     *
     * @param alarm 告警
     * @return 结果
     */
    @Override
    public int insertAlarm(Alarm alarm) {
            return this.save(alarm)?1:0;
    }

    /**
     * 修改告警
     *
     * @param alarm 告警
     * @return 结果
     */
    @Override
    public int updateAlarm(Alarm alarm) {
        return this.updateById(alarm)?1:0;
    }

    /**
     * 批量删除告警
     *
     * @param ids 需要删除的告警主键
     * @return 结果
     */
    @Override
    public int deleteAlarmByIds(Long[] ids) {
        return this.removeBatchByIds(Arrays.asList(ids))?1:0;
    }

    /**
     * 删除告警信息
     *
     * @param id 告警主键
     * @return 结果
     */
    @Override
    public int deleteAlarmById(Long id) {
        return this.removeById(id)?1:0;
    }
}